package com.sikaryofficial.system.service.impl;

import com.sikaryofficial.system.api.model.ManualExportReq;
import com.sikaryofficial.system.api.model.user.UserRegisterDTO;
import com.sikaryofficial.system.domain.dto.TrendDTO;
import com.sikaryofficial.system.domain.dto.TrendReq;
import com.sikaryofficial.system.domain.vo.ReportTrendVO;
import com.sikaryofficial.system.mapper.SysRegisterDailyMapper;
import com.sikaryofficial.system.service.ISysRegisterDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 新增注册人数日数据Service业务层处理
 *
 * @author qinjinyuan
 * @date 2024-04-07
 */
@Service
public class SysRegisterDailyServiceImpl implements ISysRegisterDailyService {
    @Autowired
    private SysRegisterDailyMapper sysRegisterDailyMapper;

    /**
     * 趋势数据查询
     *
     * @param req
     * @return
     */
    @Override
    public List<TrendDTO> getDailyByDate(TrendReq req) {
        return sysRegisterDailyMapper.getDailyByDate(req);
    }

    /**
     * 统计查询
     *
     * @param req
     * @return
     */
    @Override
    public Long countDailyByDate(TrendReq req) {
        return sysRegisterDailyMapper.countDailyByDate(req);
    }

    /**
     * @param startDate
     * @param endDate   当前时间
     * @return
     */
    @Override
    public List<ReportTrendVO> queryDaily(Date startDate, Date endDate) {
        return sysRegisterDailyMapper.queryDaily(startDate, endDate);
    }

    /**
     * @param startDate 上周星期1
     * @param endDate   当前时间
     * @return
     */
    @Override
    public List<ReportTrendVO> queryWeekly(Date startDate, Date endDate) {
        return sysRegisterDailyMapper.queryWeekly(startDate, endDate);
    }

    /**
     * @param startDate 获取上个月的第一天
     * @param endDate   当前时间
     * @return
     */
    @Override
    public List<ReportTrendVO> queryMonthly(Date startDate, Date endDate) {
        return sysRegisterDailyMapper.queryMonthly(startDate, endDate);
    }

    /**
     * @param startDate 今年的第1天
     * @param endDate   当前时间
     * @return
     */
    @Override
    public List<ReportTrendVO> queryQuarterly(Date startDate, Date endDate) {
        return sysRegisterDailyMapper.queryQuarterly(startDate, endDate);
    }

    /**
     * @param startDate 去年的第1天
     * @param endDate   当前时间
     * @return
     */
    @Override
    public List<ReportTrendVO> queryYearly(Date startDate, Date endDate) {
        return sysRegisterDailyMapper.queryYearly(startDate, endDate);
    }

    /**
     * 更新日数据
     *
     * @param genDate
     * @param subTotal
     */
    @Override
    public int saveOrUpdateDaily(Date genDate, Long subTotal,Long userId) {
        return sysRegisterDailyMapper.saveOrUpdateDaily(genDate, subTotal,userId);
    }

    /**
     * 更新周数据
     *
     * @param weekNum
     * @param subTotal
     */
    @Override
    public int saveOrUpdateWeekly(Integer weekNum, Long subTotal) {
        return sysRegisterDailyMapper.saveOrUpdateWeekly(weekNum, subTotal);
    }

    /**
     * 更新年数据
     *
     * @param genDate
     * @param subTotal
     */
    @Override
    public int saveOrUpdateMonthly(Date genDate, Long subTotal) {
        return sysRegisterDailyMapper.saveOrUpdateMonthly(genDate, subTotal);
    }

    /**
     * 更新季度数据
     *
     * @param quarterNum
     * @param subTotal
     */
    @Override
    public int saveOrUpdateQuarterly(Integer quarterNum, Long subTotal) {
        return sysRegisterDailyMapper.saveOrUpdateQuarterly(quarterNum, subTotal);
    }

    /**
     * 更新年数据
     *
     * @param genDate
     * @param subTotal
     */
    @Override
    public int saveOrUpdateYearly(Date genDate, Long subTotal) {
        return sysRegisterDailyMapper.saveOrUpdateYearly(genDate, subTotal);
    }

    @Override
    public List<UserRegisterDTO> queryRegisterDailyByTime(ManualExportReq req) {
        return sysRegisterDailyMapper.queryRegisterDailyByTime(req);
    }
}
